<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set the SAX handlers to be called when the XML document gets processed</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-sax-handler.html">xslt_set_sax_handler</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-scheme-handler.html">xslt_set_scheme_handler</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.xslt-set-sax-handlers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xslt_set_sax_handlers</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6)</p><p class="refpurpose"><span class="refname">xslt_set_sax_handlers</span> &mdash; <span class="dc-title">Set the SAX handlers to be called when the XML document gets processed</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.xslt-set-sax-handlers-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>xslt_set_sax_handlers</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$handlers</code></span>
   )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>xslt_set_sax_handlers()</strong></span> registers the SAX
   <em><code class="parameter">handlers</code></em> for the document, given a XSLT
   <em><code class="parameter">processor</code></em> resource.
  </p>
  <p class="para">
   Using <span class="function"><strong>xslt_set_sax_handlers()</strong></span> doesn&#039;t look very different than
   running a SAX parser like <span class="function"><a href="function.xml-parse.html" class="function">xml_parse()</a></span> on the result of an
   <span class="function"><a href="function.xslt-process.html" class="function">xslt_process()</a></span> transformation.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xslt-set-sax-handlers-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">
processor</code></em></dt>
<dd>
<p class="para"><acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> 处理器连接标识符，由
<span class="function"><a href="function.xslt-create.html" class="function">xslt_create()</a></span> 创建。</p></dd>


    
     <dt>
<em><code class="parameter">handlers</code></em></dt>

     <dd>

      <p class="para">
       <em><code class="parameter">handlers</code></em> should be an array in the following format:
        <div class="informalexample">
        <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$handlers&nbsp;</span><span style="color: #007700">=&nbsp;array(<br /><br />&nbsp;&nbsp;</span><span style="color: #DD0000">"document"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"start_doc"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"end_doc"</span><span style="color: #007700">),<br /><br />&nbsp;&nbsp;</span><span style="color: #DD0000">"element"&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"start_element"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"end_element"</span><span style="color: #007700">),<br /><br />&nbsp;&nbsp;</span><span style="color: #DD0000">"namespace"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"start_namespace"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"end_namespace"</span><span style="color: #007700">),<br /><br />&nbsp;&nbsp;</span><span style="color: #DD0000">"comment"&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"comment"</span><span style="color: #007700">,<br /><br />&nbsp;&nbsp;</span><span style="color: #DD0000">"pi"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"pi"</span><span style="color: #007700">,<br /><br />&nbsp;&nbsp;</span><span style="color: #DD0000">"character"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"characters"<br /><br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
        </div>

       </div>
       Where the functions follow the syntax described for the scheme handler
       functions.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        The given array does not need to contain all of the different sax
        handler elements (although it can), but it only needs to conform to
        &quot;handler&quot; =&gt; &quot;function&quot; format described above.
       </p>
      </p></blockquote>
      <p class="para">
       Each of the individual SAX handler functions are in the format below:
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">start_doc</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">end_doc</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">start_element</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>
          , <span class="methodparam"><span class="type">array</span> <code class="parameter">$attributes</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">end_element</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">start_namespace</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$prefix</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$uri</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">end_namespace</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$prefix</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">comment</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$contents</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">pi</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$target</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$contents</code></span>
          )</div>

         </p>
        </li>
        <li class="listitem">
         <p class="para">
         <div class="methodsynopsis dc-description">
          <span class="methodname"><span class="replaceable">characters</span></span>
           ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
          , <span class="methodparam"><span class="type">string</span> <code class="parameter">$contents</code></span>
          )</div>

         </p>
        </li>
       </ul>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xslt-set-sax-handlers-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 
 <div class="refsect1 examples" id="refsect1-function.xslt-set-sax-handlers-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-5438">
   <p><strong>Example #1 <span class="function"><strong>xslt_set_sax_handlers()</strong></span> Example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;From&nbsp;ohlesbeauxjours&nbsp;at&nbsp;yahoo&nbsp;dot&nbsp;fr<br />//&nbsp;Here's&nbsp;a&nbsp;simple&nbsp;example&nbsp;that&nbsp;applies&nbsp;strtoupper()&nbsp;on<br />//&nbsp;the&nbsp;content&nbsp;of&nbsp;every&nbsp;&lt;auteur&gt;&nbsp;tag&nbsp;and&nbsp;then&nbsp;displays&nbsp;the<br />//&nbsp;resulting&nbsp;XML&nbsp;tree:<br /><br /></span><span style="color: #0000BB">$xml</span><span style="color: #007700">=</span><span style="color: #DD0000">'&lt;?xml&nbsp;version="1.0"?&gt;<br />&lt;books&gt;<br />&nbsp;&lt;book&gt;<br />&nbsp;&nbsp;&lt;title&gt;Mme&nbsp;Bovary&lt;/title&gt;<br />&nbsp;&nbsp;&lt;author&gt;Gustave&nbsp;Flaubert&lt;/author&gt;<br />&nbsp;&lt;/book&gt;<br />&nbsp;&lt;book&gt;<br />&nbsp;&nbsp;&lt;title&gt;Mrs&nbsp;Dalloway&lt;/title&gt;<br />&nbsp;&nbsp;&lt;author&gt;Virginia&nbsp;Woolf&lt;/author&gt;<br />&nbsp;&lt;/book&gt;<br />&lt;/books&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$xsl</span><span style="color: #007700">=</span><span style="color: #DD0000">'&lt;?xml&nbsp;version="1.0"?&gt;<br />&lt;xsl:stylesheet&nbsp;version="1.0"&nbsp;xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;<br />&lt;xsl:output&nbsp;method="html"&nbsp;encoding="ISO-8859-1"&nbsp;indent="no"&nbsp;omit-xml-declaration="yes"/&gt;<br />&lt;xsl:template&nbsp;match="/"&gt;<br />&nbsp;&lt;xsl:for-each&nbsp;select="books/book"&gt;<br />&nbsp;&nbsp;&lt;livre&gt;<br />&nbsp;&nbsp;&nbsp;&lt;auteur&gt;&lt;xsl:value-of&nbsp;select="author/text()"/&gt;&lt;/auteur&gt;<br />&nbsp;&nbsp;&lt;/livre&gt;<br />&nbsp;&lt;/xsl:for-each&gt;<br />&lt;/xsl:template&gt;<br />&lt;/xsl:stylesheet&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Handlers&nbsp;:<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">start_document</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;start&nbsp;reading&nbsp;the&nbsp;document<br /></span><span style="color: #007700">}<br /><br />function&nbsp;</span><span style="color: #0000BB">end_document</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;end&nbsp;reading&nbsp;the&nbsp;document<br /></span><span style="color: #007700">}<br /><br />function&nbsp;</span><span style="color: #0000BB">start_element</span><span style="color: #007700">(</span><span style="color: #0000BB">$parser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attributes</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;global&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">,</span><span style="color: #0000BB">$tag</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;"</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$tag&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">;<br />}<br /><br />function&nbsp;</span><span style="color: #0000BB">end_element</span><span style="color: #007700">(</span><span style="color: #0000BB">$parser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;global&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;/"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&gt;"</span><span style="color: #007700">;<br />}<br /><br />function&nbsp;</span><span style="color: #0000BB">characters</span><span style="color: #007700">(</span><span style="color: #0000BB">$parser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;global&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">,</span><span style="color: #0000BB">$tag</span><span style="color: #007700">;<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$tag&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"auteur"&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strtoupper</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Transformation&nbsp;:<br /></span><span style="color: #0000BB">$xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$handlers&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"document"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">"start_document"</span><span style="color: #007700">,</span><span style="color: #DD0000">"end_document"</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"element"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">"start_element"</span><span style="color: #007700">,</span><span style="color: #DD0000">"end_element"</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"character"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"characters"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">xslt_set_sax_handlers</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$handlers</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xsl'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"/_xml"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">$xml</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"/_xsl"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">$xsl</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">xslt_free</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <p class="para">
   You can also use <span class="function"><a href="function.xslt-set-object.html" class="function">xslt_set_object()</a></span> if you want to
   implement your handlers in an object.
  </p>
  <div class="example" id="example-5439">
   <p><strong>Example #2 Object oriented handler</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;the&nbsp;object&nbsp;oriented&nbsp;version&nbsp;of&nbsp;the&nbsp;previous&nbsp;example<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">data_sax_handler&nbsp;</span><span style="color: #007700">{<br /><br />&nbsp;&nbsp;var&nbsp;</span><span style="color: #0000BB">$buffer</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$tag</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attrs</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;var&nbsp;</span><span style="color: #0000BB">$_xh</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">data_sax_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$xsl</span><span style="color: #007700">)<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;our&nbsp;xslt&nbsp;resource<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">xslt_set_object</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xs</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;configure&nbsp;sax&nbsp;handlers<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$handlers&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"document"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'start_document'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'end_document'</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"element"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'start_element'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'end_element'</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"character"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'characters'<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">xslt_set_sax_handlers</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$handlers</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xsl'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"/_xml"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">$xml</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"/_xsl"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">$xsl</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">xslt_free</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xh</span><span style="color: #007700">);<br /><br /><br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">start_document</span><span style="color: #007700">()<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;start&nbsp;reading&nbsp;the&nbsp;document<br />&nbsp;&nbsp;</span><span style="color: #007700">}<br /><br />&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">end_document</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;complete&nbsp;reading&nbsp;the&nbsp;document<br />&nbsp;&nbsp;</span><span style="color: #007700">}<br /><br />&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">start_element</span><span style="color: #007700">(</span><span style="color: #0000BB">$parser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attributes</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">tag&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buffer&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">attrs&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$attributes</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">end_element</span><span style="color: #007700">(</span><span style="color: #0000BB">$parser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">)<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">tag&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buffer&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;/"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">characters</span><span style="color: #007700">(</span><span style="color: #0000BB">$parser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">)<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">tag&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">'auteur'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strtoupper</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buffer&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">get_buffer</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buffer</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br /><br />}<br /><br /></span><span style="color: #0000BB">$exec&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">data_sax_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$xsl</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>
    Both examples will output:
   </p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
&lt;livre&gt;
   &lt;auteur&gt;GUSTAVE FLAUBERT&lt;/auteur&gt;
&lt;/livre&gt;
&lt;livre&gt;
   &lt;auteur&gt;VIRGINIA WOOLF&lt;/auteur&gt;
&lt;/livre&gt;
</pre></div>
   </div>
  </div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-sax-handler.html">xslt_set_sax_handler</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-scheme-handler.html">xslt_set_scheme_handler</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
